//暗黑破坏神 分组背包
#include <iostream>
using namespace std;
const int MAXN=100;
const int MAXM=500;
const int MAXP=50;
int n,m;
int c[MAXN+1],p[MAXN+1],w[MAXN+1][MAXP+1];
int maxw[MAXM+1];
int choise[MAXN+1][MAXM+1];
void output(int i,int j){
    int k=choise[i][j];
    if (i>1) output(i-1,j-k*c[i]);
    cout<<k<<endl;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) {
        cin>>c[i]>>p[i];
        for(int j=1;j<=p[i];j++) cin>>w[i][j];
    }

    for (int i=1;i<=n;i++)
        for(int m1=m;m1>=c[i];m1--)
            for(int k=1;k<=min(p[i],m1/c[i]);k++)
                if (maxw[m1]<maxw[m1-k*c[i]]+w[i][k]) {
                    maxw[m1]=maxw[m1-k*c[i]]+w[i][k];
                    choise[i][m1]=k;
                }
    int cur=m;
    for(int j=1;j<m;j++) 
        if (maxw[j]==maxw[m]) {
            cur=j;
            break;
        }
    cout<<maxw[cur]<<endl;
    output(n,cur);
}